<template>
  <div class="table">

    <div class="container">
      <div class="handle-box">
        <!--<el-button type="primary" size="mini" @click="delAll">批量删除</el-button>-->
        <!--<el-input v-model="select_word" size="mini" placeholder="查询管理员（id,用户名，昵称）" class="handle-input"></el-input>-->
        <!-- <el-button type="primary" size="mini" @click="centerDialogVisible = true">添加用户</el-button> -->


        <div class="selectBox">
          <div>
            <div> 反馈人id：</div>
            <div class="block">
              <el-input v-model="select_id" placeholder="输入问题id" class="handle-input"></el-input>
            </div>
          </div>

          <div>
            <div> 问题类型：</div>
            <div class="block">
              <el-select v-model="value" placeholder="请选择">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <!-- <el-input v-model="value" placeholder="输入问题类型" class="handle-input"></el-input> -->
            </div>
          </div>

          <!-- <div>
            <div> 问题时间：</div>
            <div class="block">
              <div class="block">
                <el-date-picker v-model="select_timer" type="datetime" placeholder="选择日期时间" class="handle-input">
                </el-date-picker>
              </div>
            </div>
          </div> -->

          <div>
            <div class="block" style="padding-top: 0px">
              <el-button type="primary" @click="selectBtn">查询</el-button>
            </div>
          </div>
        </div>



      </div>
    </div>

    <el-table class="el-table_p" size="mini" ref="multipleTable" :header-cell-style="{background:'#f4f3f9',color:'black',}" border :data="userList">
      <el-table-column width="80" prop="num" label="序号" align="center"></el-table-column>

      <!--<el-table-column prop="id" label="反馈人id" align="center"></el-table-column>-->
      <el-table-column prop="type" label="问题类型" align="center"></el-table-column>
      <el-table-column prop="content" label="问题内容" align="center"></el-table-column>
      <el-table-column prop="time" label="问题时间" align="center"></el-table-column>

      <!-- <el-table-column label="操作" align="center" v-if="level == 1"> -->
      <!-- <template slot-scope="scope">
          <el-button size="mini" type="primary" @click="handleView(scope.row)">查看所有信息</el-button>
        </template> -->
      <!-- </el-table-column> -->

    </el-table>

    <!--<div class="pagination">-->
    <!--<el-pagination-->
    <!--background-->
    <!--layout = "total,prev,pager,next"-->
    <!--:current-page="currentPage"-->
    <!--:page-size="pageSize"-->
    <!--:total="userList.length"-->
    <!--@current-change="handleCurrentChange"-->
    <!--&gt;-->
    <!--</el-pagination>-->
    <!--</div>-->

    <!-- <el-dialog title="添加管理员" :visible.sync="centerDialogVisible" width="400px" center>
      <el-form :model="registerForm" ref="registerForm" label-width="80px" :rules="rules">
        <el-form-item prop="account" label="用户名" size="mini">
          <el-input v-model="registerForm.account" placeholder="用户名"></el-input>
        </el-form-item>
        <el-form-item prop="pwd" label="密码" size="mini">
          <el-input type="password" v-model="registerForm.pwd" placeholder="密码"></el-input>
        </el-form-item>

        <el-form-item prop="nickName" label="昵称" size="mini">
          <el-input v-model="registerForm.nickName" placeholder="昵称"></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer">
        <el-button size="mini" @click="centerDialogVisible = false">取消</el-button>
        <el-button size="mini" @click="addUser" type="primary">确定</el-button>
      </span>
    </el-dialog>

    <el-dialog title="修改管理员" :visible.sync="editVisible" width="400px" center>
      <el-form :model="form" ref="form" label-width="80px" :rules="rules">
        <el-form-item prop="account" label="用户名" size="mini">
          <el-input v-model="form.account" placeholder="用户名"></el-input>
        </el-form-item>
        <el-form-item prop="nickName" label="昵称" size="mini">
          <el-input v-model="form.nickName" placeholder="昵称"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button size="mini" @click="editVisible = false">取消</el-button>
        <el-button size="mini" @click="editSave" type="primary">确定</el-button>
      </span>
    </el-dialog>

    <el-dialog title="删除管理员" :visible.sync="delVisible" width="300px" center>
      <div align="center">删除不可恢复，是否确定删除？</div>
      <span slot="footer">
        <el-button size="mini" @click="delVisible = false">取消</el-button>
        <el-button size="mini" @click="deleteRow" type="primary">确定</el-button>
      </span>
    </el-dialog> -->


    <!-- 分页 -->
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="current"
        :page-sizes="[10, 20, 30, 40]" :page-size="size" layout="total, sizes, prev, pager, next" :total="total">
      </el-pagination>

    </div>

  </div>
</template>

<script>
import { get_feedback } from '../../api/public/api';
import { mixin } from '../../../static/js/index';

export default {
  mixins: [mixin],
  data() {
    return {
      current: 1, //分页
      size: 10,
      pages: 1,
      total: 0,
      level: 0,
      userList: [],

      select_id: '',
      value: '',
      select_timer: '',

      id: "",

      centerDialogVisible: false, //添加弹窗是否显示
      editVisible: false,         //编辑弹窗是否显示
      delVisible: false,          //删除弹窗是否显示

      iden: 0,//绑定身份证信息


      options: [{
        value: '对平台意见和建议',
        label: '对平台意见和建议'
      }, {
        value: '对机构意见和建议',
        label: '对机构意见和建议'
      }, {
        value: '使用中的问题、bug反馈',
        label: '使用中的问题、bug反馈'
      }, {
        value: '其他',
        label: '其他'
      }
      ],
      value: ''


    }
  },

  created() {
    let data = {
      current: this.current,
      size: this.size
    }
    this.getData(data);

    this.level = localStorage.getItem('level')
  },

  methods: {
    // 根据条件查询订单
    selectBtn() {
      let data = {
        id: this.select_id,
        type: this.value,
        time: this.select_timer
      }
      this.getData(data);
    },

    updateData() {
      // console.log('current', current);
      let data = {
        current: this.current,
        size: this.size
      }
      this.getData(data);
    },

    // 第几页
    handleCurrentChange(val) {
      this.current = val;
      this.updateData()
    },
    handleSizeChange(val) {
      this.size = val;
      this.updateData()
    },


    //查询所有用户
    getData(data) {
      // console.log('value',this.value);


      get_feedback(data).then(res => {

        if (res.data.code == 0) {
          this.pages = res.data.data.pages
          this.total = res.data.data.total
          // this.size = res.data.data.size
          let num=1
          res.data.data.records.map(item => {
            const t = new Date(item.time)
            const y = t.getFullYear()
            const m = t.getMonth() + 1
            const d = t.getDate()
            const h = t.getHours()
            const mi = t.getMinutes()
            const s = t.getSeconds()
            item.num = num++

            item.time = y + "-" + m + "-" + d + " " + h + ":" + mi + ":" + s
          })

          this.userList = res.data.data.records
          // console.log('----', res.data.data.records);

        }


      })
    },

  },


}
</script>

<style scoped>
.handle-box {
  margin-bottom: 20px;
}

.consumer-img {
  width: 100%;
  height: 80px;
  border-radius: 5px;
  margin-bottom: 5px;
  overflow: hidden;
}

.handle-input {
  width: 300px;
  display: inline-block;
}

.pagination {
  display: flex;
  justify-content: center;
}

.block {
  text-align: right
}

.idenTure {
  color: green;
}

.idenFalse {
  color: red;
}
</style>
